# 定义编译器和编译选项
CXX = g++
CXXFLAGS = -I/usr/include/mysql -std=c++11
LDFLAGS = -L/usr/lib64/mysql -lmysqlclient -lpthread  # 添加 -lpthread

# 定义目标文件和依赖文件
TARGET = main
OBJECTS = main.o Connection.o ConnectionPool.o

# 默认目标
all: $(TARGET)

# 链接目标文件
$(TARGET): $(OBJECTS)
	$(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS)

# 编译 C++ 源文件
main.o: main.cpp ConnectionPool.h Connection.h
	$(CXX) $(CXXFLAGS) -c main.cpp

Connection.o: Connection.cpp Connection.h public.h
	$(CXX) $(CXXFLAGS) -c Connection.cpp

ConnectionPool.o: ConnectionPool.cpp ConnectionPool.h Connection.h public.h
	$(CXX) $(CXXFLAGS) -c ConnectionPool.cpp

# 清理编译生成的文件
clean:
	rm -f $(TARGET) $(OBJECTS)
